home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap17 / FontOut2 / FontOut2.c next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  1.4 KB  |  44 lines

  1. /*------------------------------------------
  2.    FONTOUT2.C -- Using Path to Outline Font
  3.                  (c) Charles Petzold, 1998
  4.   ------------------------------------------*/
  5.  
  6. #include <windows.h>
  7. #include "..\\eztest\\ezfont.h"
  8.  
  9. TCHAR szAppName [] = TEXT ("FontOut2") ;
  10. TCHAR szTitle [] = TEXT ("FontOut2: Using Path to Outline Font") ;
  11.  
  12. void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
  13. {
  14.      static TCHAR szString [] = TEXT ("Outline") ;
  15.      HFONT        hFont ;
  16.      LOGBRUSH     lb ;
  17.      SIZE         size ;
  18.  
  19.      hFont = EzCreateFont (hdc, TEXT ("Times New Roman"), 1440, 0, 0, TRUE) ;
  20.  
  21.      SelectObject (hdc, hFont) ;
  22.      SetBkMode (hdc, TRANSPARENT) ;
  23.  
  24.      GetTextExtentPoint32 (hdc, szString, lstrlen (szString), &size) ;
  25.  
  26.      BeginPath (hdc) ;
  27.      TextOut (hdc, (cxArea - size.cx) / 2, (cyArea - size.cy) / 2,
  28.                     szString, lstrlen (szString)) ;
  29.      EndPath (hdc) ;
  30.  
  31.      lb.lbStyle = BS_SOLID ;
  32.      lb.lbColor = RGB (255, 0, 0) ;
  33.      lb.lbHatch = 0 ;
  34.  
  35.      SelectObject (hdc, ExtCreatePen (PS_GEOMETRIC | PS_DOT,
  36.                                GetDeviceCaps (hdc, LOGPIXELSX) / 24,
  37.                                    &lb, 0, NULL)) ;
  38.      StrokePath (hdc) ;
  39.  
  40.      DeleteObject (SelectObject (hdc, GetStockObject (BLACK_PEN))) ;
  41.      SelectObject (hdc, GetStockObject (SYSTEM_FONT)) ;
  42.      DeleteObject (hFont) ;
  43. }
  44.